package br.com.bestOffer.conector.bean;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import br.com.bestOffer.ejb.componentes.entity.Conector;
import br.com.bestOffer.ejb.componentes.service.ComponenteServiceBean;
import br.com.bestOffer.exceptions.BestOfferListaVaziaException;
import br.com.bestOffer.util.BaseManagedBean;
import br.com.bestOffer.util.BestOfferConstantes;
import br.com.bestOffer.util.Constantes;
import br.com.bestOffer.util.WebResources;

@ManagedBean
@ViewScoped
public class ListarConectorManagedBean extends BaseManagedBean{

	private static final long serialVersionUID = 3861986942623448973L;
	
	private List<Conector> listaConector = new ArrayList<Conector>();
	
	@EJB
	private ComponenteServiceBean componentesServiceBean;
	
	@PostConstruct
	public void init() throws BestOfferListaVaziaException{ 
		listaConector = componentesServiceBean.listarConectores();
	}
	
	
	
	/**
	 * Excluir um Conector
	 * @param Conector
	 * @return
	 */
	public String excluirConector(Conector conector){
		WebResources.getFlashContext().put(Constantes.CONECTOR, conector);
		return BestOfferConstantes.EXCLUIR_CONECTOR;
	}
	
	
	/**
	 * Alterar um Conector
	 * @param placaMae
	 * @return
	 */
	public String alterarConector(Conector conector){
		WebResources.getFlashContext().put(Constantes.CONECTOR, conector);
		return BestOfferConstantes.ALTERAR_CONECTOR;
	}
	public List<Conector> getListaConector() {
		return listaConector;
	}
	public void setListaConector(List<Conector> listaConector) {
		this.listaConector = listaConector;
	}

}
